In [1]:
import numpy as np
import btmorph3
import matplotlib.pyplot as plt
from copy import deepcopy
%matplotlib inline
#np.random.seed(0)
per = btmorph3.Perturbation(iterations = 1000,verbose=0)
M = {'mean': {'Nbranch': 10,
'Nendpoint': 10,
'Nnodes': 300,
'angle_branch': 2.4,
#'diameter': 1,
#'distance_from_root2': 0, #30,
'distance_from_root': 50,
'global_angle': .3,
'length_to_parent': 1,
'local_angle': 3,
'initial_segments': 4,
#'slope': .1,
'discrepancy_space': 60,
'ratio_euclidian_neuronal': 1},
'variance': {'Nbranch': 1,
'Nendpoint': 10,
'Nnodes': 5,
'angle_branch': .2,
#'diameter': 1,
#'distance_from_root2': .5,
'distance_from_root': 10,
'global_angle': .100,
'length_to_parent': 1,
'local_angle': .1,
'initial_segments': 1,
#'slope': .1,
'discrepancy_space': 5,
'ratio_euclidian_neuronal': .01}}
per.set_measure(M)
per.set_probability(np.array([.15,.35,0,0,.15,0,0,0,.2,.2,0,0]))
per.fit()
gen = per.neuron
btmorph3.visualize.plot_2D(gen,show_radius=False);
gen_old = deepcopy(per.neuron)
per1 = btmorph3.Perturbation(neuron=per.neuron, iterations = 1,verbose=0)
per1.set_measure(M)
per1.set_probability(np.array([0,0,0,0,0,0,0,0,0,0,0,1]))
per1.fit()
btmorph3.visualize.plot_2D(per1.neuron,show_radius=False);
In [ ]:
per.normal(3)
In [ ]:
new = btmorph3.Neuron(file_format = 'only list of nodes',input_file = deepcopy(per1.neuron.nodes_list))
gen = per1.neuron
In [ ]:
print('parent index')
print new.parent_index - gen.parent_index
print('child_index')
print new.child_index - gen.child_index
print('branch_order')
print new.branch_order - gen.branch_order
print('angle_branch')
print new.angle_branch - gen.angle_branch
print('distance_from_root')
print new.distance_from_root - gen.distance_from_root
print('length_to_parent')
print new.length_to_parent - gen.length_to_parent
print('local_angle')
print new.local_angle - gen.local_angle
print('angle_global')
print new.angle_global - gen.angle_global
print('location')
print new.location - gen.location
In [ ]:
new.root.xyz
In [ ]:
M = gen.connection
m = new.connection
M1, M2 = np.where(~np.isnan(M))
m1, m2 = np.where(~np.isnan(m))
plt.plot(M[M1,M2] - m[m1,m2])
In [ ]:
np.random.normal(size = 3)
In [ ]:
gen.branch_order
In [ ]:
for i in range(12):
print gen.features.keys()[i]
a = gen.features.values()[i] - new.features.values()[i]
print a
In [ ]:
new.branch_order
In [ ]:
print new.angle_global
print gen.angle_global
In [ ]:
len(per1.neuron.nodes_list)
In [ ]:
np.where(np.where(~np.isnan(new.overall_connectivity_matrix)) == np.where(~np.isnan(gen.overall_connectivity_matrix)))
In [ ]:
np.where(~np.isnan(gen.overall_connectivity_matrix))[1] - np.where(~np.isnan(new.overall_connectivity_matrix))[1]
In [ ]:
np.where(~np.isnan(new.overall_connectivity_matrix))[1]
In [ ]:
print new.features
print gen.features
In [ ]:
gen.ext_red_list - new.ext_red_list
In [ ]:
print new.local_angle
print gen.local_angle
In [ ]:
new.nodes_list[19].children
In [ ]:
gen.local_angle[25]
In [ ]:
new.n_soma
In [ ]:
new.overall_connectivity_matrix[:,3]
In [ ]:
gen.overall_connectivity_matrix[:,43]
In [ ]:
gen_old.overall_connectivity_matrix[:,4]
In [ ]:
print np.where(~np.isnan(gen.overall_connectivity_matrix))[0]
In [ ]:
print np.where(~np.isnan(new.overall_connectivity_matrix))[0]
In [ ]:
print np.where(~np.isnan(gen_old.overall_connectivity_matrix))[0]
In [ ]:
plt.imshow(gen.overall_connectivity_matrix)
In [ ]:
plt.imshow(new.overall_connectivity_matrix)
In [ ]:
plt.imshow(gen_old.overall_connectivity_matrix)
In [ ]:
new.get_index_for_no_soma_node(new.nodes_list[12].parent)
In [ ]:
new.get_index_for_no_soma_node(new.nodes_list[3].children[0])
In [ ]:
gen.overall_connectivity_matrix[8,3]
In [ ]:
import os
import sys
sys.path.append("/Users/RoozbehFarhoudi/Documents/Repos/Generative-Models-of-Neuron-Morphology/")
import btmorph3
import numpy as np
import matplotlib.pyplot as plt
from copy import deepcopy
%matplotlib inline
#np.random.seed(0)
per = btmorph3.Perturbation(iterations = 20000,verbose=0)
M = {'mean': {
# 'Nbranch': 20,
'Nendpoint': 20,
'Nnodes': 400,
#'angle_branch': 2.4,
#'diameter': 1,
#'distance_from_root2': 0, #30,
#'distance_from_root': 50,
#'global_angle': .3,
#'length_to_parent': 1,
# 'local_angle': 3,
'initial_segments': 4,
#'slope': .1,
#'discrepancy_space': 60,
'ratio_euclidian_neuronal': 1
},
'variance': {
# 'Nbranch': 1,
'Nendpoint': 1,
'Nnodes': 5,
# 'angle_branch': .2,
#'diameter': 1,
#'distance_from_root2': .5,
# 'distance_from_root': 10,
# 'global_angle': .100,
#'length_to_parent': 1,
# 'local_angle': .1,
'initial_segments': .3,
#'slope': .1,
#'discrepancy_space': 5,
'ratio_euclidian_neuronal': .01
}}
per.set_ratio_red_to_ext(.1)
per.set_measure(M)
per.set_probability(np.array([.5,.5,0,0,0,0,0,0,0,0]))
per.fit()
gen = per.neuron
btmorph3.visualize.plot_2D(gen,show_radius=False);
In [ ]:
plt.plot(np.transpose(per.trend_normal[:,2000:]));
plt.legend(M['mean'].keys(),bbox_to_anchor=(1.7, 1))
#plt.ylim([-1,1])
In [ ]:
plt.plot(sum(per.trend,0));
In [ ]:
per.neuron.features
In [ ]:
plt.plot(np.transpose(per.trend_normal[:,500:]));
plt.legend(M['mean'].keys(),bbox_to_anchor=(1.7, 1))
#plt.ylim([-1,1])